home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / frmmain.cs < prev    next >
Encoding:
Text File  |  2004-07-15  |  26.1 KB  |  868 lines

  1. //******************************************************************'
  2. //*                                                                *'
  3. //*                      TurboCAD for Windows                      *'
  4. //*                   Copyright (c) 1993 - 2004                    *'
  5. //*             International Microcomputer Software, Inc.         *'
  6. //*                            (IMSI)                              *'
  7. //*                      All rights reserved.                      *'
  8. //*                                                                *'
  9. //******************************************************************'
  10.  
  11. using System;
  12. using System.Drawing;
  13. using System.Collections;
  14. using System.ComponentModel;
  15. using System.Windows.Forms;
  16. using System.Data;
  17. using GXMPSLib;
  18. using GXRendersLib;
  19. //using IMSIGX;
  20. namespace TCADClientTest
  21. {
  22.     /// <summary>
  23.     /// Summary description for Form1.
  24.     /// </summary>
  25.  
  26.     public class frmMain : System.Windows.Forms.Form
  27.     {
  28.         private System.Windows.Forms.StatusBar statusBar1;
  29.         private System.Windows.Forms.MainMenu mainMenu1;
  30.         private System.Windows.Forms.MenuItem menuItem1;
  31.         private System.Windows.Forms.MenuItem menuItem2;
  32.         private System.Windows.Forms.MenuItem menuItem3;
  33.         private System.Windows.Forms.MenuItem menuItem16;
  34.         private System.Windows.Forms.OpenFileDialog openFileDialog1;
  35.         System.Windows.Forms.TabControl tabControl1;
  36.         private System.ComponentModel.IContainer components;
  37.         private System.Windows.Forms.MenuItem mnu_OpenFile;
  38.         private System.Windows.Forms.ToolBar tbMain;
  39.         private System.Windows.Forms.ToolBarButton tbbViewPlan;
  40.         private System.Windows.Forms.ToolBarButton tbbVewBottom;
  41.         private System.Windows.Forms.ToolBarButton tbbViewFront;
  42.         private System.Windows.Forms.ToolBarButton tbbViewLeft;
  43.         private System.Windows.Forms.ToolBarButton tbbViewRight;
  44.         private System.Windows.Forms.ToolBarButton tbbViewISO_NE;
  45.         private System.Windows.Forms.ToolBarButton tbbViewISO_SE;
  46.         private System.Windows.Forms.ToolBarButton tbbViewISO_NW;
  47.         private System.Windows.Forms.ToolBarButton tbbViewISO_SW;
  48.         private System.Windows.Forms.ImageList imageList1;
  49.         private System.Windows.Forms.MenuItem mnu_FileExit;
  50.         private System.Windows.Forms.MenuItem mnuZoomIn;
  51.         private System.Windows.Forms.MenuItem mnuZoomOut;
  52.         private System.Windows.Forms.HScrollBar hSBar;
  53.         private System.Windows.Forms.VScrollBar vSBar;
  54.         private System.Windows.Forms.MenuItem mnu_CloseFile;
  55.         private System.Windows.Forms.MenuItem mnu_Select;
  56.         private System.Windows.Forms.MenuItem mnu_SelectAll;
  57.         private System.Windows.Forms.MenuItem mnu_Camera;
  58.         private System.Windows.Forms.MenuItem mnu_CameraTop;
  59.         private System.Windows.Forms.MenuItem mnu_CameraLeft;
  60.         private System.Windows.Forms.MenuItem mnu_CameraRight;
  61.         private System.Windows.Forms.MenuItem mnu_CameraFront;
  62.         private System.Windows.Forms.MenuItem mnu_CameraBack;
  63.         private System.Windows.Forms.MenuItem mnu_CameraISO_SE;
  64.         private System.Windows.Forms.MenuItem mnu_CameraISO_NE;
  65.         private System.Windows.Forms.MenuItem mnu_CameraISO_SW;
  66.         private System.Windows.Forms.MenuItem mnu_CameraProperties;
  67.         private System.Windows.Forms.MenuItem mnu_CameraISO_NW;
  68.         private System.Windows.Forms.MenuItem mnu_ZoomToExtents;
  69.         private System.Windows.Forms.MenuItem mnu_Refresh;
  70.         TCADApp tcApp = null;
  71.         public frmMain()
  72.         {
  73.             //
  74.             // Required for Windows Form Designer support
  75.             //
  76.             InitializeComponent();
  77.             if (tcApp  == null)
  78.             {
  79.                 //TCADApp tcApp1;
  80.                 tcApp =  new TCADApp ();
  81.                 //this.tcApp = tcApp;
  82.             }
  83.             tcApp.InitTCApp ();
  84.             
  85.             //
  86.             // TODO: Add any constructor code after InitializeComponent call
  87.             //
  88.             ControlsEnabler();
  89.             MyResize();
  90.  
  91. //            tcApp = null;
  92.         }
  93.  
  94.         /// <summary>
  95.         /// Clean up any resources being used.
  96.         /// </summary>
  97.         protected override void Dispose( bool disposing )
  98.         {
  99.             if( disposing )
  100.             {
  101.                 if (components != null) 
  102.                 {
  103.                     components.Dispose();
  104.                 }
  105.             }
  106.             
  107.             if (tcApp != null)
  108.             {
  109.             //    delete tcApp.TCADApplicatiom
  110.             }
  111.             base.Dispose( disposing );
  112.         }
  113.  
  114.         #region Windows Form Designer generated code
  115.         /// <summary>
  116.         /// Required method for Designer support - do not modify
  117.         /// the contents of this method with the code editor.
  118.         /// </summary>
  119.         private void InitializeComponent()
  120.         {
  121.             this.components = new System.ComponentModel.Container();
  122.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMain));
  123.             System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
  124.             this.tbMain = new System.Windows.Forms.ToolBar();
  125.             this.tbbViewPlan = new System.Windows.Forms.ToolBarButton();
  126.             this.tbbViewLeft = new System.Windows.Forms.ToolBarButton();
  127.             this.tbbViewFront = new System.Windows.Forms.ToolBarButton();
  128.             this.tbbViewRight = new System.Windows.Forms.ToolBarButton();
  129.             this.tbbVewBottom = new System.Windows.Forms.ToolBarButton();
  130.             this.tbbViewISO_SE = new System.Windows.Forms.ToolBarButton();
  131.             this.tbbViewISO_SW = new System.Windows.Forms.ToolBarButton();
  132.             this.tbbViewISO_NE = new System.Windows.Forms.ToolBarButton();
  133.             this.tbbViewISO_NW = new System.Windows.Forms.ToolBarButton();
  134.             this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  135.             this.statusBar1 = new System.Windows.Forms.StatusBar();
  136.             this.mainMenu1 = new System.Windows.Forms.MainMenu();
  137.             this.menuItem1 = new System.Windows.Forms.MenuItem();
  138.             this.mnu_OpenFile = new System.Windows.Forms.MenuItem();
  139.             this.mnu_CloseFile = new System.Windows.Forms.MenuItem();
  140.             this.menuItem16 = new System.Windows.Forms.MenuItem();
  141.             this.mnu_FileExit = new System.Windows.Forms.MenuItem();
  142.             this.menuItem2 = new System.Windows.Forms.MenuItem();
  143.             this.mnu_Select = new System.Windows.Forms.MenuItem();
  144.             this.mnu_SelectAll = new System.Windows.Forms.MenuItem();
  145.             this.menuItem3 = new System.Windows.Forms.MenuItem();
  146.             this.mnu_Camera = new System.Windows.Forms.MenuItem();
  147.             this.mnu_CameraTop = new System.Windows.Forms.MenuItem();
  148.             this.mnu_CameraLeft = new System.Windows.Forms.MenuItem();
  149.             this.mnu_CameraRight = new System.Windows.Forms.MenuItem();
  150.             this.mnu_CameraFront = new System.Windows.Forms.MenuItem();
  151.             this.mnu_CameraBack = new System.Windows.Forms.MenuItem();
  152.             this.mnu_CameraISO_SE = new System.Windows.Forms.MenuItem();
  153.             this.mnu_CameraISO_SW = new System.Windows.Forms.MenuItem();
  154.             this.mnu_CameraISO_NE = new System.Windows.Forms.MenuItem();
  155.             this.mnu_CameraISO_NW = new System.Windows.Forms.MenuItem();
  156.             this.mnu_CameraProperties = new System.Windows.Forms.MenuItem();
  157.             this.mnuZoomIn = new System.Windows.Forms.MenuItem();
  158.             this.mnuZoomOut = new System.Windows.Forms.MenuItem();
  159.             this.mnu_ZoomToExtents = new System.Windows.Forms.MenuItem();
  160.             this.mnu_Refresh = new System.Windows.Forms.MenuItem();
  161.             this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
  162.             this.tabControl1 = new System.Windows.Forms.TabControl();
  163.             this.hSBar = new System.Windows.Forms.HScrollBar();
  164.             this.vSBar = new System.Windows.Forms.VScrollBar();
  165.             this.SuspendLayout();
  166.             // 
  167.             // tbMain
  168.             // 
  169.             this.tbMain.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
  170.             this.tbMain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  171.             this.tbMain.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
  172.                                                                                       this.tbbViewPlan,
  173.                                                                                       this.tbbViewLeft,
  174.                                                                                       this.tbbViewFront,
  175.                                                                                       this.tbbViewRight,
  176.                                                                                       this.tbbVewBottom,
  177.                                                                                       this.tbbViewISO_SE,
  178.                                                                                       this.tbbViewISO_SW,
  179.                                                                                       this.tbbViewISO_NE,
  180.                                                                                       this.tbbViewISO_NW});
  181.             this.tbMain.DropDownArrows = true;
  182.             this.tbMain.ImageList = this.imageList1;
  183.             this.tbMain.Location = new System.Drawing.Point(0, 0);
  184.             this.tbMain.Name = "tbMain";
  185.             this.tbMain.ShowToolTips = true;
  186.             this.tbMain.Size = new System.Drawing.Size(648, 29);
  187.             this.tbMain.TabIndex = 0;
  188.             this.tbMain.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbMain_ButtonClick);
  189.             // 
  190.             // tbbViewPlan
  191.             // 
  192.             this.tbbViewPlan.ImageIndex = 0;
  193.             this.tbbViewPlan.ToolTipText = "World Plan";
  194.             // 
  195.             // tbbViewLeft
  196.             // 
  197.             this.tbbViewLeft.ImageIndex = 1;
  198.             // 
  199.             // tbbViewFront
  200.             // 
  201.             this.tbbViewFront.ImageIndex = 2;
  202.             // 
  203.             // tbbViewRight
  204.             // 
  205.             this.tbbViewRight.ImageIndex = 3;
  206.             // 
  207.             // tbbVewBottom
  208.             // 
  209.             this.tbbVewBottom.ImageIndex = 4;
  210.             // 
  211.             // tbbViewISO_SE
  212.             // 
  213.             this.tbbViewISO_SE.ImageIndex = 5;
  214.             // 
  215.             // tbbViewISO_SW
  216.             // 
  217.             this.tbbViewISO_SW.ImageIndex = 6;
  218.             // 
  219.             // tbbViewISO_NE
  220.             // 
  221.             this.tbbViewISO_NE.ImageIndex = 7;
  222.             // 
  223.             // tbbViewISO_NW
  224.             // 
  225.             this.tbbViewISO_NW.ImageIndex = 8;
  226.             // 
  227.             // imageList1
  228.             // 
  229.             this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
  230.             this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
  231.             this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  232.             // 
  233.             // statusBar1
  234.             // 
  235.             this.statusBar1.Location = new System.Drawing.Point(0, 321);
  236.             this.statusBar1.Name = "statusBar1";
  237.             this.statusBar1.Size = new System.Drawing.Size(648, 16);
  238.             this.statusBar1.TabIndex = 1;
  239.             this.statusBar1.TabStop = true;
  240.             // 
  241.             // mainMenu1
  242.             // 
  243.             this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  244.                                                                                       this.menuItem1,
  245.                                                                                       this.menuItem2,
  246.                                                                                       this.menuItem3});
  247.             // 
  248.             // menuItem1
  249.             // 
  250.             this.menuItem1.Index = 0;
  251.             this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  252.                                                                                       this.mnu_OpenFile,
  253.                                                                                       this.mnu_CloseFile,
  254.                                                                                       this.menuItem16,
  255.                                                                                       this.mnu_FileExit});
  256.             this.menuItem1.Text = "&File";
  257.             // 
  258.             // mnu_OpenFile
  259.             // 
  260.             this.mnu_OpenFile.Index = 0;
  261.             this.mnu_OpenFile.Text = "&Open";
  262.             this.mnu_OpenFile.Click += new System.EventHandler(this.mnuOpenFile_Click);
  263.             // 
  264.             // mnu_CloseFile
  265.             // 
  266.             this.mnu_CloseFile.Index = 1;
  267.             this.mnu_CloseFile.Text = "&Close";
  268.             // 
  269.             // menuItem16
  270.             // 
  271.             this.menuItem16.Index = 2;
  272.             this.menuItem16.Text = "&Print Preview";
  273.             // 
  274.             // mnu_FileExit
  275.             // 
  276.             this.mnu_FileExit.Index = 3;
  277.             this.mnu_FileExit.Shortcut = System.Windows.Forms.Shortcut.AltF4;
  278.             this.mnu_FileExit.Text = "&Exit";
  279.             this.mnu_FileExit.Click += new System.EventHandler(this.mnu_FileExit_Click);
  280.             // 
  281.             // menuItem2
  282.             // 
  283.             this.menuItem2.Index = 1;
  284.             this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  285.                                                                                       this.mnu_Select,
  286.                                                                                       this.mnu_SelectAll});
  287.             this.menuItem2.Text = "&Edit";
  288.             // 
  289.             // mnu_Select
  290.             // 
  291.             this.mnu_Select.Index = 0;
  292.             this.mnu_Select.Text = "&Select";
  293.             // 
  294.             // mnu_SelectAll
  295.             // 
  296.             this.mnu_SelectAll.Index = 1;
  297.             this.mnu_SelectAll.Text = "&Select All";
  298.             // 
  299.             // menuItem3
  300.             // 
  301.             this.menuItem3.Index = 2;
  302.             this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  303.                                                                                       this.mnu_Camera,
  304.                                                                                       this.mnuZoomIn,
  305.                                                                                       this.mnuZoomOut,
  306.                                                                                       this.mnu_ZoomToExtents,
  307.                                                                                       this.mnu_Refresh});
  308.             this.menuItem3.Text = "View";
  309.             // 
  310.             // mnu_Camera
  311.             // 
  312.             this.mnu_Camera.Index = 0;
  313.             this.mnu_Camera.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  314.                                                                                        this.mnu_CameraTop,
  315.                                                                                        this.mnu_CameraLeft,
  316.                                                                                        this.mnu_CameraRight,
  317.                                                                                        this.mnu_CameraFront,
  318.                                                                                        this.mnu_CameraBack,
  319.                                                                                        this.mnu_CameraISO_SE,
  320.                                                                                        this.mnu_CameraISO_SW,
  321.                                                                                        this.mnu_CameraISO_NE,
  322.                                                                                        this.mnu_CameraISO_NW,
  323.                                                                                        this.mnu_CameraProperties});
  324.             this.mnu_Camera.Text = "&Camera";
  325.             // 
  326.             // mnu_CameraTop
  327.             // 
  328.             this.mnu_CameraTop.Index = 0;
  329.             this.mnu_CameraTop.Text = "&Top";
  330.             // 
  331.             // mnu_CameraLeft
  332.             // 
  333.             this.mnu_CameraLeft.Index = 1;
  334.             this.mnu_CameraLeft.Text = "&Left";
  335.             // 
  336.             // mnu_CameraRight
  337.             // 
  338.             this.mnu_CameraRight.Index = 2;
  339.             this.mnu_CameraRight.Text = "&Right";
  340.             // 
  341.             // mnu_CameraFront
  342.             // 
  343.             this.mnu_CameraFront.Index = 3;
  344.             this.mnu_CameraFront.Text = "&Front";
  345.             // 
  346.             // mnu_CameraBack
  347.             // 
  348.             this.mnu_CameraBack.Index = 4;
  349.             this.mnu_CameraBack.Text = "&Back";
  350.             // 
  351.             // mnu_CameraISO_SE
  352.             // 
  353.             this.mnu_CameraISO_SE.Index = 5;
  354.             this.mnu_CameraISO_SE.Text = "ISO_SE";
  355.             this.mnu_CameraISO_SE.Click += new System.EventHandler(this.mnuCameraISO_SE_Click);
  356.             // 
  357.             // mnu_CameraISO_SW
  358.             // 
  359.             this.mnu_CameraISO_SW.Index = 6;
  360.             this.mnu_CameraISO_SW.Text = "ISO_SW";
  361.             // 
  362.             // mnu_CameraISO_NE
  363.             // 
  364.             this.mnu_CameraISO_NE.Index = 7;
  365.             this.mnu_CameraISO_NE.Text = "ISO_NE";
  366.             // 
  367.             // mnu_CameraISO_NW
  368.             // 
  369.             this.mnu_CameraISO_NW.Index = 8;
  370.             this.mnu_CameraISO_NW.Text = "ISO_NW";
  371.             // 
  372.             // mnu_CameraProperties
  373.             // 
  374.             this.mnu_CameraProperties.Index = 9;
  375.             this.mnu_CameraProperties.Text = "&Properties";
  376.             this.mnu_CameraProperties.Click += new System.EventHandler(this.mnu_CameraProperties_Click);
  377.             // 
  378.             // mnuZoomIn
  379.             // 
  380.             this.mnuZoomIn.Index = 1;
  381.             this.mnuZoomIn.Shortcut = System.Windows.Forms.Shortcut.F3;
  382.             this.mnuZoomIn.Text = "Zoom &In";
  383.             this.mnuZoomIn.Click += new System.EventHandler(this.mnuZoomIn_Click);
  384.             // 
  385.             // mnuZoomOut
  386.             // 
  387.             this.mnuZoomOut.Index = 2;
  388.             this.mnuZoomOut.Shortcut = System.Windows.Forms.Shortcut.F4;
  389.             this.mnuZoomOut.Text = "Zoom &Out";
  390.             this.mnuZoomOut.Click += new System.EventHandler(this.mnuZoomOut_Click);
  391.             // 
  392.             // mnu_ZoomToExtents
  393.             // 
  394.             this.mnu_ZoomToExtents.Index = 3;
  395.             this.mnu_ZoomToExtents.Text = "&Zoom To Extents";
  396.             this.mnu_ZoomToExtents.Click += new System.EventHandler(this.mnu_ZoomToExtents_Click);
  397.             // 
  398.             // mnu_Refresh
  399.             // 
  400.             this.mnu_Refresh.Index = 4;
  401.             this.mnu_Refresh.Shortcut = System.Windows.Forms.Shortcut.F5;
  402.             this.mnu_Refresh.Text = "&Refresh";
  403.             this.mnu_Refresh.Click += new System.EventHandler(this.mnu_Refresh_Click);
  404.             // 
  405.             // tabControl1
  406.             // 
  407.             this.tabControl1.AccessibleRole = System.Windows.Forms.AccessibleRole.Document;
  408.             this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Bottom;
  409.             this.tabControl1.CausesValidation = false;
  410.             this.tabControl1.HotTrack = true;
  411.             this.tabControl1.ItemSize = new System.Drawing.Size(0, 14);
  412.             this.tabControl1.Location = new System.Drawing.Point(0, 56);
  413.             this.tabControl1.Multiline = true;
  414.             this.tabControl1.Name = "tabControl1";
  415.             this.tabControl1.SelectedIndex = 0;
  416.             this.tabControl1.ShowToolTips = ((bool)(configurationAppSettings.GetValue("tabControl1.ShowToolTips", typeof(bool))));
  417.             this.tabControl1.Size = new System.Drawing.Size(608, 216);
  418.             this.tabControl1.TabIndex = 6;
  419.             this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
  420.             // 
  421.             // hSBar
  422.             // 
  423.             this.hSBar.LargeChange = 160;
  424.             this.hSBar.Location = new System.Drawing.Point(264, 312);
  425.             this.hSBar.Maximum = 16000;
  426.             this.hSBar.Name = "hSBar";
  427.             this.hSBar.Size = new System.Drawing.Size(344, 16);
  428.             this.hSBar.SmallChange = 16;
  429.             this.hSBar.TabIndex = 8;
  430.             this.hSBar.Value = 8000;
  431.             this.hSBar.Visible = false;
  432.             this.hSBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this.hSBar_Scroll);
  433.             // 
  434.             // vSBar
  435.             // 
  436.             this.vSBar.LargeChange = 160;
  437.             this.vSBar.Location = new System.Drawing.Point(608, 56);
  438.             this.vSBar.Maximum = 16000;
  439.             this.vSBar.Name = "vSBar";
  440.             this.vSBar.Size = new System.Drawing.Size(16, 208);
  441.             this.vSBar.SmallChange = 16;
  442.             this.vSBar.TabIndex = 9;
  443.             this.vSBar.Value = 8000;
  444.             this.vSBar.Visible = false;
  445.             this.vSBar.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vSBar_Scroll);
  446.             // 
  447.             // frmMain
  448.             // 
  449.             this.AccessibleRole = System.Windows.Forms.AccessibleRole.Application;
  450.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  451.             this.AutoScroll = ((bool)(configurationAppSettings.GetValue("Form1.AutoScroll", typeof(bool))));
  452.             this.CausesValidation = ((bool)(configurationAppSettings.GetValue("Form1.CausesValidation", typeof(bool))));
  453.             this.ClientSize = new System.Drawing.Size(648, 337);
  454.             this.ControlBox = ((bool)(configurationAppSettings.GetValue("Form1.ControlBox", typeof(bool))));
  455.             this.Controls.Add(this.vSBar);
  456.             this.Controls.Add(this.hSBar);
  457.             this.Controls.Add(this.tabControl1);
  458.             this.Controls.Add(this.statusBar1);
  459.             this.Controls.Add(this.tbMain);
  460.             this.HelpButton = ((bool)(configurationAppSettings.GetValue("Form1.HelpButton", typeof(bool))));
  461.             this.KeyPreview = true;
  462.             this.Menu = this.mainMenu1;
  463.             this.Name = "frmMain";
  464.             this.Text = "TCADClient Test APP";
  465.             this.ResumeLayout(false);
  466.  
  467.         }
  468.         #endregion
  469.  
  470.         /// <summary>
  471.         /// The main entry point for the application.
  472.         /// </summary>
  473.         [STAThread]
  474.         static void Main() 
  475.         {
  476.             
  477.             Application.Run(new frmMain());
  478.             
  479.         }
  480.  
  481.         private void mnuOpenFile_Click(object sender, System.EventArgs e)
  482.         {
  483.             statusBar1.Text = "";
  484.             tcApp.OpenDrawing(tabControl1);
  485.             if (tcApp.gxDrawing != null)
  486.             {
  487.                 statusBar1.Text = tcApp.gxDrawing.Name;
  488.             }
  489.             ControlsEnabler();
  490.             tabControl1.Refresh ();
  491.             if (tcApp.gxView != null)
  492.             {
  493.                 tcApp.gxView.ZoomToExtents ();
  494.             }
  495.         }
  496.  
  497.         public TabPage GetCurrentTab()
  498.         {
  499.             TabPage tabPage1;
  500.             System.Collections.IEnumerator pN;
  501.             pN = tabControl1.TabPages.GetEnumerator ();
  502.             pN.MoveNext() ;
  503.             tabPage1 = (TabPage) pN.Current;
  504.             return tabPage1;        
  505.         }
  506.         protected override void OnResize(EventArgs e)
  507.         {
  508.             
  509.             // TODO:  Add Form1.OnResize implementation
  510.             MyResize();
  511.             base.OnResize (e);
  512.         }
  513.  
  514.         public void MyResize()
  515.         {
  516.             tabControl1.Top =  tbMain.Height;
  517.             tabControl1.Left = tbMain.Left;
  518.             tabControl1.Width = base.Size.Width  - vSBar.Width  - 10 ;  //this.Width;
  519.             tabControl1.Height = base.Height - tbMain.Height - statusBar1.Height-hSBar.Height  - 40; 
  520.             vSBar.Left = tabControl1.Left + tabControl1.Width ;
  521.             vSBar.Top = tabControl1.Top ;
  522.             vSBar.Height = tabControl1.Height - hSBar.Height ;
  523.             hSBar.Left  = tbMain.Left + tabControl1.Width/2;
  524.             hSBar.Top = tbMain.Height + tabControl1.Height - hSBar.Height;
  525.             hSBar.Width = tabControl1.Width/2 ;
  526.             if (tcApp != null)
  527.             {
  528.                 if (tcApp.gxView != null)
  529.                 {
  530.                     tcApp.gxView.AutoRedraw = false;
  531.                     tcApp.gxView.ScreenWidth = tabControl1.SelectedTab.Width;
  532.                     tcApp.gxView.ScreenHeight = tabControl1.SelectedTab.Height ;
  533.                     tcApp.gxView.AutoRedraw = true;
  534.                     tcApp.gxView.Refresh ();
  535.                     
  536.                 }
  537.             }
  538.         }
  539.  
  540.         private void mnu_Refresh_Click(object sender, System.EventArgs e)
  541.         {
  542.             //tabControl1.Refresh ();
  543.             tcApp.gxView.Refresh ();
  544.         }
  545.  
  546.         private void mnu_ZoomToExtents_Click(object sender, System.EventArgs e)
  547.         {
  548.             vSBar.Value = (vSBar.Maximum - vSBar.Minimum )/2;
  549.             hSBar.Value = (hSBar.Maximum - hSBar.Minimum )/2;
  550.             tcApp.gxView.Update = false;
  551.             tcApp.gxView.ZoomToExtents ();
  552.             tabControl1.Refresh ();    
  553.             tcApp.gxView.Update = true;
  554.         }
  555.  
  556.         private void button3_Click(object sender, System.EventArgs e)
  557.         {
  558.             tcApp.OpenDrawing(tabControl1);
  559.             tabControl1.Refresh ();
  560.         }
  561.  
  562.         private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
  563.         {
  564.             TabPage tp;
  565.             object spName = "";
  566.             object oSpaceModePropName = "TileMode";
  567.             object oSpaceMode = 0;
  568.             bool bPaperSpace = false;
  569.             tp = tabControl1.SelectedTab ;
  570.             if (tp == null)
  571.             {
  572.                 return;
  573.             }
  574.             IMSIGX.Property pProp = null;
  575.             GXMPSLib.PaperSpaces pss = null;
  576.             GXMPSLib.PaperSpace ps = null;
  577.  
  578.             spName = tp.Text;
  579.             if (tcApp == null)
  580.             {
  581.                 return;
  582.             }
  583.             if (tcApp.gxDrawing == null)
  584.             {
  585.                 return;
  586.             }
  587.             if (spName.Equals("Model") == false)
  588.             {
  589.                 pss = (PaperSpaces) tcApp.gxDrawing.PaperSpaces;
  590.                 ps = pss.get_Item(ref spName);
  591.                 oSpaceMode = IMSIGX.ImsiSpaceModeType.imsiPaperSpace;
  592.                 bPaperSpace = true;///pProp = tcApp.gxDrawing.Properties.get_Item(ref oSpaceModePropName);
  593.                 
  594.             }
  595.             else
  596.             {
  597.                 if (tcApp != null)
  598.                 {
  599.                     if (tcApp.gxView !=null)
  600.                     {
  601.                         oSpaceMode = IMSIGX.ImsiSpaceModeType.imsiModelSpace;
  602.                     }
  603.                 }                
  604.             }
  605.             
  606.             pProp = tcApp.gxDrawing.Properties.get_Item(ref oSpaceModePropName);
  607.             if (pProp != null)
  608.             {
  609.                 pProp.set_Value (0, ref oSpaceMode);
  610.                 
  611.                 
  612.             }
  613.             if (tcApp.gxView != null)
  614.             {
  615.                 tcApp.gxView.SpaceMode = (IMSIGX.ImsiSpaceModeType)oSpaceMode  ;
  616.             }
  617.  
  618.             if (bPaperSpace && ps != null)
  619.             {
  620.                 ps.Activate ();
  621.             }
  622.             tbMain.Enabled = (!bPaperSpace && true);
  623.             mnu_Camera.Enabled = (!bPaperSpace && true);
  624.             if (tcApp != null)
  625.             {
  626.                 if (tcApp.gxView !=null)
  627.                 {
  628.                     tcApp.gxView.AutoRedraw = false;
  629.                     tcApp.gxView.Update = false;
  630.                     tcApp.gxView.Delete ();
  631.                     
  632.                     tcApp.AddView ((int)tp.Handle );
  633.                     tcApp.gxView.AutoRedraw = false;
  634.  
  635.  
  636.                     tcApp.gxView.Update = true;
  637.                     tcApp.gxView.MappingMode = 1;
  638.                     tcApp.gxView.FixedAspectRatio = true;
  639.                     
  640.                     tabControl1.Visible = false;
  641.                     tabControl1.Refresh ();
  642.                     tabControl1.Visible = true;
  643.                     tcApp.gxView.AutoRedraw = true;
  644.                     tcApp.gxView.ZoomToExtents ();
  645.                     vSBar.Value = (vSBar.Maximum - vSBar.Minimum )/2;
  646.                     hSBar.Value = (hSBar.Maximum - hSBar.Minimum )/2;
  647.                     
  648.                 }
  649.             }
  650.         
  651.         }
  652.  
  653.         private void mnuCameraISO_SE_Click(object sender, System.EventArgs e)
  654.         {
  655.             if (tcApp != null)
  656.             {
  657.                 if (tcApp.gxView !=null)
  658.                 {
  659.                     if (tcApp.gxView.SpaceMode == 0 )
  660.                     {
  661.                         return; // do nothing if paper space
  662.                     }
  663.                     tcApp.SetView (tcApp.gxView, 5);
  664.                     vSBar.Value = (vSBar.Maximum - vSBar.Minimum )/2;
  665.                     hSBar.Value = (hSBar.Maximum - hSBar.Minimum )/2;
  666.                     tabControl1.Refresh ();
  667.                     tcApp.gxView.Refresh ();
  668.                 }
  669.             }
  670.         }
  671.  
  672.         private void tbMain_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
  673.         {
  674.             int iindex = 0;
  675.             if (tcApp != null)
  676.             {
  677.                 if (tcApp.gxView !=null)
  678.                 {
  679.                     iindex = e.Button.ImageIndex ;
  680.                     vSBar.Value = (vSBar.Maximum - vSBar.Minimum )/2;
  681.                     hSBar.Value = (hSBar.Maximum - hSBar.Minimum )/2;
  682.                     tcApp.SetView (tcApp.gxView , iindex);
  683.                                         
  684.                     tabControl1.Refresh ();
  685.                     tcApp.gxView.Refresh ();
  686.                 }
  687.             }
  688.             
  689.                 
  690.         }
  691.  
  692.         private void mnu_FileExit_Click(object sender, System.EventArgs e)
  693.         {
  694.             this.Dispose (true);
  695.         }
  696.  
  697.         private void mnuZoomIn_Click(object sender, System.EventArgs e)
  698.         {
  699.             if (tcApp != null)
  700.             {
  701.                 if (tcApp.gxView !=null)
  702.                 {
  703.                     tcApp.Zoom (tcApp.gxView, 0.8);
  704.                     tabControl1.Refresh ();    
  705.                     tcApp.gxView.Update = true;
  706.                 }
  707.             }            
  708.         }
  709.  
  710.         private void mnuZoomOut_Click(object sender, System.EventArgs e)
  711.         {
  712.             if (tcApp != null)
  713.             {
  714.                 if (tcApp.gxView !=null)
  715.                 {
  716.                     tcApp.Zoom (tcApp.gxView, 1.2);
  717.                     tabControl1.Refresh ();
  718.                     tcApp.gxView.Update = true;
  719.                 }
  720.             }            
  721.         
  722.         }
  723.  
  724.  
  725.  
  726.     
  727.         protected override void OnMouseWheel(MouseEventArgs e)
  728.         {
  729.             // TODO:  Add Form1.OnMouseWheel implementation
  730.             if (tcApp != null)
  731.             {
  732.                 if (tcApp.gxView !=null)
  733.                 {
  734.                     if (e.Delta > 0)
  735.                     {
  736.                         tcApp.Zoom (tcApp.gxView, 0.8);
  737.                     }
  738.                     else
  739.                     {
  740.                         tcApp.Zoom (tcApp.gxView, 1.2);
  741.                     }
  742.                     tabControl1.Refresh ();
  743.                     tcApp.gxView.Update = true;
  744.                 }
  745.             }            
  746.             base.OnMouseWheel (e);
  747.         }
  748.     
  749.         protected override void OnKeyPress(KeyPressEventArgs e)
  750.         {
  751.             char eKey;
  752.             eKey = e.KeyChar;
  753.             // TODO:  Add Form1.OnKeyPress implementation
  754.             if (tcApp != null)
  755.             {
  756.                 if (tcApp.gxView !=null)
  757.                 {
  758.                     switch(e.KeyChar )
  759.                     {
  760.                         case ((char)43)://'+': // zoom In
  761.                             tcApp.Zoom (tcApp.gxView, 0.8);
  762.                             break;
  763.                         case ((char)45)://'-': // Zoom Out
  764.                             tcApp.Zoom (tcApp.gxView, 1.2);
  765.                             break;
  766.                         case ((char) 40):
  767.                         default:
  768.                             break;
  769.                     }
  770.                     tabControl1.Refresh ();
  771.                     tcApp.gxView.Update = true;
  772.                 }
  773.             }
  774.             base.OnKeyPress (e);
  775.         }
  776.  
  777.         public void ControlsEnabler()
  778.         {
  779.             bool bScrollBarsVisible = false;
  780.             if (tcApp != null)
  781.             {
  782.                 if (tcApp.gxView !=null)
  783.                 {
  784.                     bScrollBarsVisible = true;
  785.                 }
  786.             }
  787.             hSBar.Visible = bScrollBarsVisible;
  788.             vSBar.Visible = bScrollBarsVisible;
  789.             
  790.         }
  791.  
  792.         private void hSBar_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
  793.         {
  794.             if (tcApp != null)
  795.             {
  796.                 if (tcApp.gxView !=null)
  797.                 {
  798.                     UpdateHScroll();
  799.                 }
  800.             }
  801.         }
  802.  
  803.         public void UpdateHScroll()
  804.         {
  805.             long ScrollVal;
  806.             ScrollVal = hSBar.Value;
  807.             if (ScrollVal != tcApp.ScrollLast.x )
  808.             {
  809.                 double Range;
  810.                 double Delta;
  811.                 Range = hSBar.Maximum  - hSBar.Minimum;
  812.                 Delta = ScrollVal - tcApp.ScrollLast.x;
  813.                 if (Delta == Range/2)
  814.                 {
  815.                     Delta = 0;
  816.                 }
  817.                 Delta = Delta *  0.1;
  818.                 tcApp.gxView.Update = false;
  819.                 tcApp.ViewScrollBy (Delta, 0);
  820.                 tabControl1.Refresh();
  821.                 tcApp.gxView.Update = true;
  822.             }
  823.             tcApp.ScrollLast.x = ScrollVal; //Remember last value
  824.         }
  825.  
  826.         public void UpdateVScroll()
  827.         {
  828.             long ScrollVal;
  829.             ScrollVal = vSBar.Value;
  830.             if (ScrollVal != tcApp.ScrollLast.y)
  831.             {
  832.                 double Range;
  833.                 double Delta;
  834.                 Range = vSBar.Maximum  - vSBar.Minimum;
  835.                 Delta = ScrollVal - tcApp.ScrollLast.y;
  836.                 if (Delta == Range/2)
  837.                 {
  838.                     Delta = 0;
  839.                 }
  840.                 Delta = -Delta *  0.1;
  841.                 tcApp.gxView.Update = false;
  842.                 tcApp.ViewScrollBy(0, Delta);
  843.                 tabControl1.Refresh();
  844.                 tcApp.gxView.Update = true;
  845.             }
  846.             tcApp.ScrollLast.y  = ScrollVal; //Remember last value
  847.         }
  848.  
  849.         private void vSBar_Scroll(object sender, System.Windows.Forms.ScrollEventArgs e)
  850.         {
  851.             UpdateVScroll();
  852.         }
  853.  
  854.         private void mnu_CameraProperties_Click(object sender, System.EventArgs e)
  855.         {
  856.             MessageBox.Show ("Add your code here");
  857.         }
  858.     
  859.     
  860.         protected override void OnPaint(PaintEventArgs e)
  861.         {
  862.             // TODO:  Add Form1.OnPaint implementation
  863.             tabControl1.Invalidate();
  864.             base.OnPaint (e);
  865.         }
  866.     }
  867. }
  868.